import java.util.*;

public class example4_5 {
    public static void main(String[] args) {
        String s = "this is a string";
        StringTokenizer st = new StringTokenizer(s, ", ");//空格与逗号做分隔
        int number = st.countTokens();
        while (st.hasMoreTokens()) {
            String str = st.nextToken();
            System.out.println(str);
        }
        System.out.println("s共有单词：" + number + "个");
    }
}
